package eerbaar.shared.internal.persist.load;

import eerbaar.shared.exceptions.GameException;
import eerbaar.shared.persist.PersistConstants;
import eerbaar.shared.persist.node.NodeDecorator;
import eerbaar.shared.tree.IAttributes;
import eerbaar.shared.tree.INode;


public class MyNodeDecorator extends NodeDecorator {

    public MyNodeDecorator(INode node) {
        super(node);
    }

    public String getPrivateClassName() throws GameException {

        IAttributes a = node().getAttributes();
        String result = a.get(String.class, PersistConstants.PRIVATE_CLASS);

        if (result == null) {
            result = INode.class.getName();
        }

        return result;
    }

    public void setPrivateClassName(String name) {

        if (name.equals(INode.class.getName())) {
            return;
        }

        IAttributes a = node().getAttributes();
        a.set(String.class, PersistConstants.PRIVATE_CLASS, name);
    }

}
